<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('采购单信息列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>采购单号：</label>
                            <input type="text" name="purId"/>
                        </li>

                        <li class="select-time">
                            <label>采购时间： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
                        </li>

                        <li class="select-time">
                            <label>金额： </label>
                            <input type="text"  id="startMoney" placeholder="最小金额" name="params[beginMoney]"/>
                            <span>-</span>
                            <input type="text"   id="endMoney" placeholder="最大金额" name="params[endMoney]"/>
                        </li>

                        <li>
                            <label>审核状态：</label>
                            <select name="status">
                                <option value="">请选择</option>
                                <option value="1">未审核</option>
                                <option value="2">审核中</option>
                                <option value="3">审核通过</option>
                                <option value="4">审核未通过</option>
                            </select>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>


        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="purchase:repo:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="purchase:repo:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="purchase:repo:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>

<th:block th:include="include :: footer" />

<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('purchase:repo:edit')}]];
    var removeFlag = [[${@permission.hasPermi('purchase:repo:remove')}]];
    var checkFlag = [[${@permission.hasPermi('purchase:repo:check')}]];
    var detailsFlag= [[${@permission.hasPermi('purchase:repo:details')}]];
    var storageFlag= [[${@permission.hasPermi('purchase:repo:put')}]];
    var prefix = ctx + "purchase/repo";


    function numFormat(num) {
        var c = (num.toString().indexOf ('.') !== -1) ? num.toLocaleString() : num.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
        return c;
    }

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            checkUrl: prefix+"/check/{id}",
            detailsUrl: prefix+"/details/{id}",
            storageUrl: prefix+"/put/{id}",
            exportUrl: prefix + "/export",
            modalName: "采购单信息",
            columns: [{
                checkbox: true
            },

                {
                    field: 'purId',
                    title: '采购单号'
                    // visible:false
                },
                {
                    field: 'purTime',
                    title: '采购时间'
                },
                {
                    field: 'total',
                    title: '金额',
                    formatter: function(value) {
                        var qianzhui ='￥';
                        if (value != null){
                            return qianzhui + numFormat(value);
                        }
                    }
                },
                {
                    field: 'sysUser.userName',
                    title: '操作人'
                },
                {
                    field: 'status',
                    title: '审核状态',
                    formatter: function(value) {
                        if (value==1){
                            return "未审核"
                        }if (value==2){
                            return "审核中"
                        }if (value==3){
                            return "审核通过"
                        }if (value==4){
                            return "审核未通过"
                        }
                    }

                },
                {
                    field: 'sysUser1.userName',
                    title: '审核人'
                },
                {
                    field: 'checkTime',
                    title: '审核时间'
                },
                {
                    title: '操作',
                    align: 'left',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.status==1){
                            actions.push('<a class="btn btn-success btn-xs ' + checkFlag + '" href="javascript:void(0)" onclick="$.operate.check1(\'' + row.purId + '\')"><i class="fa fa-edit"></i>提交审核</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.purId + '\')"><i class="fa fa-edit"></i>修改</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.purId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }else if(row.status==2){
                            actions.push('<a class="btn btn-success btn-xs ' + detailsFlag + '" href="javascript:void(0)" onclick="$.operate.purdetail1(\'' + row.purId + '\')"><i class="fa fa-edit"></i>查看详情</a> ');
                        }else if(row.status==3){
                            actions.push('<a class="btn btn-success btn-xs ' + detailsFlag + '" href="javascript:void(0)" onclick="$.operate.purdetail1(\'' + row.purId + '\')"><i class="fa fa-edit"></i>查看详情</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + storageFlag + '" href="javascript:void(0)" onclick="$.operate.detail2(\'' + row.purId + '\')"><i class="fa fa-edit"></i>入库详情</a> ');
                        }else if(row.status==4){
                            actions.push('<a class="btn btn-success btn-xs ' + checkFlag + '" href="javascript:void(0)" onclick="$.operate.check1(\'' + row.purId + '\')"><i class="fa fa-edit"></i>提交审核</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.purId + '\')"><i class="fa fa-edit"></i>修改</a> ');
                        };
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>